package cn.tedu.mybatisdb.mapper;

import cn.tedu.mybatisdb.pojo.Product;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ProductMapper {
    @Insert("INSERT INTO product(title,price,stock) "+
            "VALUES (#{title},#{price},#{stock})")
    int insertProduct(Product product);

    @Delete("DELETE FROM product WHERE id=#{id}")
    int deleteProduct(Integer id);

    @Update("UPDATE product " +
            "SET title=#{title}, price=#{price}, stock=#{stock} " +
            "WHERE id=#{id}")
    int updateProduct(Product product);

    @Select("SELECT id,title,price,stock " +
            "FROM product " +
            "WHERE id=#{id}" )
    Product selectProductById(Integer id);
}
